/**
 * 二维矩阵，#周围的点是终点，问任选起点，可以到达的最多点数量是多少。
 * 对每个可以做起点的点搜索一遍即可。但这个应该会超时。因为没有用记忆化。
 */
#include <bits/stdc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vll = vector<llt>;

template<typename T>
void input(vector<T> & a, int n){
    a.assign(n + 1, {});
    for(int i=1;i<=n;++i) cin >> a[i];
    return;
}

template<typename T>
istream & operator >> (istream & is, vector<T> & v){
    for(auto & i : v) is >> i;
    return is;
}

int const DR[] = {-1, 1, 0, 0};
int const DC[] = {0, 0, -1, 1};

int N;
int M;
vector<string> Board;
vector<vi> G;
vector<vi> Flag;


void proc(int r, int c)
{
    Flag[r][c] = 2;
    for(int dr,dc,o=0;o<4;++o){
        dr = r + DR[o];
        dc = c + DC[o];
        if(0 <= dr and dr < N and 0 <= dc and dc < M and '.' == Board[dr][dc]){
            Flag[dr][dc] = 1;
        }
    }
}

int f(int r, int c){
    // cout << "proc: " << r << ", " << c << endl;
    queue<pii> q;
    Flag[r][c] = 3;
    q.push({r, c});
    int ans = 1;
    int sz = 0;
    vector<pii> vec;
    while(sz = q.size()){
        while(sz--){
            auto h = q.front(); q.pop();
            for(int nr,nc,i=0;i<4;++i){
                nr = h.first + DR[i];
                nc = h.second + DC[i];
                if(0 <= nr and nr < N and 0 <= nc and nc < M){
                    if(0 == Flag[nr][nc]){
                        ans += 1;
                        Flag[nr][nc] = 3;
                        q.push({nr, nc});
                        // cout << "next: " << nr << ", " << nc << endl;
                    }else if(1 == Flag[nr][nc]){
                        ans += 1;
                        Flag[nr][nc] = 11;
                        vec.emplace_back(nr, nc);
                    }
                }

            }
        }
    }
    for(const auto & p : vec) Flag[p.first][p.second] = 1;
    return ans;
}

void work(){
    cin >> N >> M;
    Board.assign(N, {});
    cin >> Board;

    Flag.assign(N, vi(M, 0));
    int jingcnt = 0;
    for(int i=0;i<N;++i)for(int j=0;j<M;++j){
        if('#' == Board[i][j]){
            proc(i, j);
            jingcnt += 1;
        }
    }
    if(jingcnt == N * M) return (void)(cout << "0\n");

    int ans = 1;
    for(int i=0;i<N;++i)for(int j=0;j<M;++j){
        if(0 == Flag[i][j]){
            ans = max(ans, f(i, j));
        }
    }
    cout << ans << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}